package com.demo.component;

import org.springframework.beans.factory.BeanNameAware;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * @Author YuanYuan
 * @Date 2023/2/10
 * @Time 15:19
 */

//@Component
public class BeanLifeComponent implements BeanNameAware {

    @Override
    public void setBeanName(String s) {
        System.out.println("执行通知");
    }

    @PostConstruct
    public void postConstruct() {
        System.out.println("执行了PostConstruct初始化方法");
    }

    public void init() {
        System.out.println("执行了 init-method 初始化方法");
    }

    @PreDestroy
    public void preDestory() {
        System.out.println("执行了PreDestroy销毁方法");
    }

}



